/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_adjust_population.h

	$Header: /heroes4/script_adjust_population.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( SCRIPT_ADJUST_POPULATION_H_INCLUDED )
#define SCRIPT_ADJUST_POPULATION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "abstract_script_action.h"
#include "script_action_type.h"

// --------------------------------------------------------------------------
// t_script_adjust_population class
// --------------------------------------------------------------------------

class t_script_adjust_population : public t_abstract_script_action
{
public:
	// Constructor
	t_script_adjust_population(int direction);

	// Member functions
	virtual void	execute(t_script_context_hero const& context) const;
	virtual void	execute(t_script_context_town const& context) const;
	virtual void	execute(t_script_context_object const& context) const;
	virtual void	execute(t_script_context_army const& context) const;
	virtual void	execute(t_script_context_global const& context) const;

	int				get_adjustment() const;
	int				get_dwelling_number() const;
	virtual bool	read(
						std::streambuf &	stream,
						int					version );
	virtual bool	read_from_map(
						std::streambuf &	stream,
						int					format_version );
	virtual bool	write( std::streambuf & stream ) const;

private:
	// Data members
	int	m_dwelling_number; // Add k_town_dwelling_1 to convert to t_town_building enum
	int	m_adjustment;

	int m_direction;
};

// --------------------------------------------------------------------------
// t_script_adjust_population inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_script_adjust_population::t_script_adjust_population(int direction)
	:	m_dwelling_number( 0 ),
		m_adjustment( 0 ),
		m_direction( direction )
{
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline int t_script_adjust_population::get_adjustment() const
{
	return m_adjustment;
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline int t_script_adjust_population::get_dwelling_number() const
{
	return m_dwelling_number;
}

// --------------------------------------------------------------------------
// t_script_decrease_population class
// --------------------------------------------------------------------------

class t_script_decrease_population : public t_script_adjust_population
{
public:
	t_script_decrease_population() : t_script_adjust_population(-1) {}
};

SPECIALIZE_SCRIPT_ACTION( k_script_action_decrease_population, t_script_decrease_population );

// --------------------------------------------------------------------------
// t_script_increase_population class
// --------------------------------------------------------------------------

class t_script_increase_population : public t_script_adjust_population
{
public:
	t_script_increase_population() : t_script_adjust_population(1) {}

};

SPECIALIZE_SCRIPT_ACTION( k_script_action_increase_population, t_script_increase_population );

#endif // !defined( SCRIPT_ADJUST_POPULATION_H_INCLUDED )
